<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        function f() {
            var elementById = document.getElementById('sex1');
            var ele = document.getElementById('sex');
            var elementById1 = document.getElementById('sg');
            var elementById2 = document.getElementById('sg1');
            var jg = document.getElementById('jg');
            if (elementById.checked == "" && ele.checked == "") {
                alert("没选择儿童性别！ ");
                return;
            }  if (elementById.checked ==true && ele.checked == true) {
                alert("只能选择一个性别！请重新选择");
                return;
            }
            if (elementById.checked == true) {
                if (elementById1 >= 55 && elementById1 <= 250 && elementById2 >= 55 && elementById2 <= 250) {
                    jg.value = "小孩未来的身高是:" + (elementById1.value + elementById2.value) / 2 * 1.08 + "厘米";
                }
            }
            if (ele.checked == true) {
                if (elementById1 >= 55 && elementById1 <= 250 && elementById2 >= 55 && elementById2 <= 250) {
                    jg.value = "小孩未来的身高是:" + (elementById1.value*0.932 + elementById2.value) / 2 + "厘米";
                }
            }
        }
    </script>
</head>
<body>
<font color="#9acd32" size="5">儿童身高预测</font><br>
儿童性别;
<input type="checkbox" name="sex1" value="man">男
<input type="checkbox" name="sex" value="woman">女
<br>
爸爸的身高：<input type="text" id="sg" value="" size="10">厘米<br>
妈妈的身高：<input type="text" id="sg1" value="" size="10">厘米<br>
<input type="button" value="查看结果" color="yellow" onload="f()">
<input type="button" value="重新测试" color="yellow" onload="f()">
<br>
测试结果：
<input type="text" id="jg" value="">
</body>
</html>